﻿using System.Security.Cryptography.X509Certificates;
using Common;
using Event;

namespace Entity
{
    public sealed class ShowEntitySuccessEventArgs : BaseEventArgs
    {
        public ShowEntitySuccessEventArgs()
        {
            Entity = null;
        }

        /// <summary>
        /// 获取显示成功的实体
        /// </summary>
        public IEntity Entity
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取加载持续时间
        /// </summary>
        public float Duration
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取用户自定义数据
        /// </summary>
        public object UserData
        {
            get;
            private set;
        }
        
        /// <summary>
        /// 创建显示实体成功事件
        /// </summary>
        /// <param name="entity">加载成功的实体</param>
        /// <param name="duration">加载持续时间</param>
        /// <param name="userData">用户自定义数据</param>
        /// <returns>创建的显示实体成功事件</returns>
        public static ShowEntitySuccessEventArgs Create(IEntity entity, float duration, object userData)
        {
            ShowEntitySuccessEventArgs showEntitySuccessEventArgs = ReferencePool.Acquire<ShowEntitySuccessEventArgs>();
            showEntitySuccessEventArgs.Entity = entity;
            showEntitySuccessEventArgs.Duration = duration;
            showEntitySuccessEventArgs.UserData = userData;
            return showEntitySuccessEventArgs;
        }

        /// <summary>
        /// 这里不需要
        /// </summary>
        public override int Id { get; }

        /// <summary>
        /// 清理显示实体成功事件
        /// </summary>
        public override void Clear()
        {
            Entity = null;
            Duration = 0;
            UserData = null;
        }

    }
}